<template>
	<view>
		<view class="huang">
			<view class="vieweom">
				<input v-model="code" class="ingphuan" placeholder="输入兑换码"/>
			</view>
			<view @click="taphuan" class="quedhuan flex-ju-c">
				确认兑换</view>
		</view>
		<view class="con " style="padding-bottom:15px;">
			<view v-for="(item,index) in list" :key="index" class="bgfff flex-ju-b  vvvs">
				<view class="flex1">
					<view>{{item.obj_model_cn}}</view>
					<view class="flex-ju-b">
						<view class="mtg">{{item.obj_id_cn}}</view>
						<view class="times">{{item.create_time}}</view>			
					</view>
				</view>
			</view>
		</view>
	</view>
	
</template>

<script>
	export default {
		data() {
			return {
				code:"",
				list:"",
				page:1
			}
		},
		onReachBottom() {
			console.log(33)
			this.page++
			this.getlist()
		},
		onLoad() {
			this.getlist()
		},
		methods: {
			getlist(){
				this.$http('v1.exchangelist', {
					rows:7,
					page:this.page
				}).then((res) => {
					if (res.code == 1) {
						this.list = [...this.list,...res.data]
					}
				})
			},
			taphuan(){
				this.$http('v1.exchange', {
					code:this.code,
					
				}).then((res) => {
					if (res.code == 1) {
						uni.showToast({
							title:"兑换成功"
						})
						setTimeout(()=>{
							this.list=[]
							this.page=1
							this.getlist()
						},800)
					}
				})
			},
		}
	}
</script>

<style lang="scss">
	.mtg{
		margin-top:5px;
	}
	.times{
		color:#ccc;
		margin-top:5px;
		font-size: 24rpx;
	}
	.vvvs{
		margin-top:12px;
		border-radius: 15px;
		padding: 10px 12px;
	}
	.quedhuan{
		width: 92%;
		background: #a084f0;
		margin: auto;
		border-radius: 20rpx;
		padding-top: 10px;
		padding-bottom: 10px;
		color:#fff;
		margin-top:30rpx;
	}
	.vieweom{
		width:60%;
		margin: auto;
		padding-top:30rpx;
	}
.huang{
	background: #fff;
	padding-bottom: 30rpx;
}
.ingphuan{
	height: 40px;
	border-radius:20rpx;
	text-align: center;
	background: #ece6fd;
}
</style>
